export function usePaging() {
  const total = ref<number>(10)

  const queryParams = reactive<{ [key: string]: unknown }>({
    pageNum: 1,
    pageSize: 10,
  })

  function setQueryParms(obj: object) {
    Object.assign(queryParams, obj)
  }

  async function loadData(getData) {
    const reponse = await getData(queryParams)
    total.value = reponse.total
    return reponse
  }

  return {
    loadData,
    total,
    queryParams,
    setQueryParms,
  }
}
